CentOS 7
Sponsored Link

Install TensorFlow (CPU Only)
2018/01/23
 
Install TensorFlow which is Machine Learning Library by Google.
To use TensorFlow, it's possible to select APIs for some languages like Python, C, Java, Go.
On this example, use Python 2.7. (The version requirements is Python 2.7 or Python 3.3 and later)
Furthermore on this example, Install officially provided binary module.
For binary module, it provides GPU supported and no GPU supported version.
On here, install no GPU supported version.
[1] Install required packages first.
# install from EPEL

[root@dlp ~]#
yum --enablerepo=epel -y install python2-pip python-devel
[2] Install TensorFlow.
# update pip

[root@dlp ~]#
easy_install -U pip

Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 9.0.1

[root@dlp ~]#
pip install --upgrade tensorflow

Collecting tensorflow
  Downloading tensorflow-1.4.1-cp27-cp27mu-manylinux1_x86_64.whl (40.7MB)

.....
.....

Successfully installed backports.weakref-1.0.post1 bleach-1.5.0 enum34-1.1.6 
funcsigs-1.0.2 futures-3.2.0 html5lib-0.9999999 markdown-2.6.11 mock-2.0.0 
numpy-1.14.0 pbr-3.1.1 protobuf-3.5.1 setuptools-38.4.0 six-1.11.0 tensorflow-1.4.1 
tensorflow-tensorboard-0.4.0 werkzeug-0.14.1 wheel-0.30.0
[3] Verify installation with a common user.
For the messages [CPU supports ***], it's no ploblem. It means TensorFlow Binary has compiled without CPU feature listed in the messages.
[cent@dlp ~]$
vi hello_tensorflow.py

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

[cent@dlp ~]$
python ./hello_tensorflow.py

2018-01-24 16:25:18.660059: I tensorflow/core/platform/cpu_feature_guard.cc:137]
Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
Hello, TensorFlow!
[4] Try to experience TensorFlow to run officially provided basic Model.
[cent@dlp ~]$
mkdir tensorflow

[cent@dlp ~]$
cd tensorflow

[cent@dlp tensorflow]$
git clone https://github.com/tensorflow/models.git

[cent@dlp tensorflow]$
cd models/official/mnist

[cent@dlp mnist]$
python mnist.py

INFO:tensorflow:Using default config.

.....
.....

INFO:tensorflow:Starting evaluation at 2018-01-25-02:14:41
INFO:tensorflow:Restoring parameters from /tmp/mnist_model/model.ckpt-48000
INFO:tensorflow:Finished evaluation at 2018-01-25-02:14:49
INFO:tensorflow:Saving dict for global step 48000: accuracy = 0.9931, global_step = 48000, loss = 0.029771108

Evaluation results:
        {'loss': 0.029771108, 'global_step': 48000, 'accuracy': 0.9931}
[5] To use TensorBoard, it's possible to visualize the results of learnings. By default results are outputs unser /tmp directory, so specify it like follows. After running TensorBoard, access to the URL which is displayed, then it's possible to see visualized results.
[cent@dlp ~]$
tensorboard --logdir=/tmp/mnist_model

TensorBoard 0.4.0 at http://dlp.srv.world:6006 (Press CTRL+C to quit)
 
Tweet